#ifndef __PROTOCOL_HEADER_FILE_
#define __PROTOCOL_HEADER_FILE_
#include <WinSock2.h>

#include <list>
using namespace std;





#define IN
#define OUT

enum _PE_RET_DEF
{
	PE_RET_OK =	0,
	PE_RET_FAIL,
	PE_RET_NOT_ENOUGH_MEM,
	PE_RET_INVALID_PARA,
	PE_RET_NETWORK_ERROR,
	PE_RET_DATA_END,
	PE_RET_ALREADY_EXIST,
	PE_RET_ITEM_SAVED,
	PE_RET_WRONG_PWD,
	PE_RET_CMP_GREATER,
	PE_RET_CMP_LOWER,
	PE_RET_CMP_EQUAL,
	PE_RET_DEVICE_NOT_CONNECTED,
	PE_RET_NEED_EXIT
};


#define		SUB_BTN_COLOR										RGB(20,120,80)
#define		SUB_BTN_SEL_COLOR									RGB(167,218,60)
#define		SUB_BTN_FONT_COLOR									RGB(255,255,255)
#define		SUB_BTN_FONT_FOCUS_COLOR							RGB(0,0,0)


#define		SUB_BTN1_COLOR										RGB(40,182,249)
#define		SUB_BTN1_SEL_COLOR									RGB(167,218,60)
#define		SUB_BTN1_FONT_COLOR									RGB(255,255,255)
#define		SUB_BTN1_FONT_FOCUS_COLOR							RGB(0,0,0)

#define		SUB_BTN2_COLOR										RGB(238,47,65)
#define		SUB_BTN2_SEL_COLOR									RGB(167,218,60)
#define		SUB_BTN2_FONT_COLOR									RGB(255,255,255)
#define		SUB_BTN2_FONT_FOCUS_COLOR							RGB(0,0,0)

#define		SUB_BTN3_COLOR										RGB(167,218,60)
#define		SUB_BTN3_SEL_COLOR									RGB(20,120,80)
#define		SUB_BTN3_FONT_COLOR									RGB(0,0,0)
#define		SUB_BTN3_FONT_FOCUS_COLOR							RGB(255,255,255)

#define		BTN_FONT_COLOR										RGB(122,121,121)
#define		BTN_BK_FOCUS_COLOR									RGB(255,255,255)
#define		BTN_BK_COLOR										RGB(253,206,54)

#define		DLG_BK_COLOR										RGB(248,248,248)
#define		SUB_DLG_BK_COLOR									RGB(255,255,255)


enum _PE_MSG_DEF
{
	WM_PE_MIN_MSG = WM_USER + 1,
	WM_STAT_PROGRESS,
	WM_FOLDER_TYPE,
	WM_STAT_DONE,
	WM_PE_MAX_MSG
};

#define		APP_VER											1

#define 	PE_MAX_HTTP_DATA_LEN								(50 * 1024 * 1024)

#define		ONE_SECOND											(10 * 1000 * 1000)

#define		PE_LOG_FILE_NAME									"MailStat_Log.txt"

enum _OUTLOOK_VER_DEF
{
	PE_OL_VER_UNKONW =	0,
	PE_OL_VER_2013,
	PE_OL_VER_2010,
	PE_OL_VER_2007,
	PE_OL_VER_2003,
};


enum _STAT_TYPE
{
	STAT_TYPE_UNKNOW =	0,
	STAT_TYPE_BY_YEAR,
	STAT_TYPE_BY_MONTH,
	STAT_TYPE_BY_WEEK,
	STAT_TYPE_BY_DAY,
	STAT_TYPE_BY_HOUR,
};


enum _MAIL_TYPE
{
	MAIL_TYPE_UNKNOW =	0,
	MAIL_TYPE_SENT,
	MAIL_TYPE_RECV,
};



#pragma pack(1)

typedef struct _STAT_ITEM
{
	//DWORD dwStatType;
	DWORD SentCount;
	DWORD RecvCount;
	SYSTEMTIME stSortTime;
} STAT_ITEM;


typedef struct _SENDER_ITEM
{
	TCHAR szName[255];
	TCHAR szMail[255];
	DWORD dwMailCount;
} SENDER_ITEM;


typedef struct _PE_COMMON_SETTING 
{
	DWORD dwVer;
	DWORD dwIsRegistered;
	DWORD dwTrialStartTime;
	DWORD dwUseDefaultPst;
	TCHAR szSN[255];
	TCHAR szPst[255];
} PE_COMMON_SETTING;


typedef struct _MAIL_ITEM
{
	DWORD		dwType;
	FILETIME 	ftCreateTime;
	//FILETIME 	ftCreateTime;
	TCHAR		szSenderName[255];
	TCHAR		szSenderMail[255];
	TCHAR		szReceiverName[255];
	TCHAR		szRecvMail[255];
	DWORD		dwSize;
}MAIL_ITEM;


extern void PEWriteLog2File(TCHAR *szLogInfo);

extern CRITICAL_SECTION cs4Log;
#define PEWriteLog(tszInfo)	do{ \
	EnterCriticalSection(&cs4Log);\
	TCHAR *tszLog = (TCHAR*)malloc(PE_MAX_HTTP_DATA_LEN);\
	_stprintf(tszLog,_T("[%S:%u]  %s"),__FILE__,__LINE__,tszInfo);\
	PEWriteLog2File(tszLog);\
	free(tszLog);\
	LeaveCriticalSection(&cs4Log);\
}while(0);

#pragma pack()

#endif

